﻿using System.Collections.Generic;
using System.Xml;

namespace Wedn.Core.Utility
{
    /// <summary>
    /// 配置查询助手类
    /// </summary>
    public class ConfigHelper
    {
        protected static Dictionary<string, string> LoadTemplateRule()
        {
            Dictionary<string, string> temp = new Dictionary<string, string>();
            string urlFilePath = System.Web.HttpContext.Current.Server.MapPath(Config.SiteRoot + "config/TemplateRule.config");
            System.Xml.XmlDocument xml = new System.Xml.XmlDocument();
            xml.Load(urlFilePath);
            XmlNode root = xml.SelectSingleNode("TemplateRule");
            foreach (XmlNode item in root)
            {
                if (item.Name == "#comment")
                    continue;
                temp.Add(item.Attributes["pagetype"].Value, item.Attributes["template"].Value);
            }
            return temp;
        }
        protected static Dictionary<string, string> LoadConfig()
        {
            Dictionary<string, string> temp = new Dictionary<string, string>();
            string urlFilePath = System.Web.HttpContext.Current.Server.MapPath(Config.SiteRoot + "config/Wedn.Net.config");
            XmlDocument xml = new XmlDocument();
            xml.Load(urlFilePath);
            XmlNode root = xml.SelectSingleNode("BlogSetting");
            foreach (XmlNode item in root)
            {
                if (item.Name == "#comment")
                    continue;
                temp.Add(item.Name, item.InnerText);
            }
            return temp;
        }
    }
}